"""
    @Author  ：思念 
    @File    ：9.浏览器滚动.py
    @Date    ：2025/4/8 10:55 
"""
import time
from selenium import webdriver


webdriver = webdriver.Chrome()
webdriver.get("https://36kr.com/")


# 绝对定位
absolute_code = "window.scrollTo(0, 1000)"
webdriver.execute_script(absolute_code)
time.sleep(2)
# 相对定位
relative_code = "window.scrollBy(0, {})"
for i in range(1, 10):
    webdriver.execute_script(relative_code.format(i * 100))
    time.sleep(1)
webdriver.execute_script(relative_code)


webdriver.quit()